
package gui;

import java.awt.BorderLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class MyFrame extends JFrame implements ActionListener {
	private JTextField nameTf;
	private JPasswordField  psdPf;
	private JButton loginBtn;
	private JButton cancelBtn;
	public MyFrame() {
		this.setSize(400, 260);
		this.setResizable(false);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		init();
		addEvent();
		this.setVisible(true);
	}
	private void init(){
		this.setLayout(null);
		nameTf=new JTextField();
		psdPf=new JPasswordField();
		loginBtn=new JButton("login");
		cancelBtn=new JButton("cancel");
		nameTf.setBounds(20, 20, 300, 40);
		psdPf.setBounds(20, 80, 300, 40);
		loginBtn.setBounds(60, 140, 90, 40);
		cancelBtn.setBounds(200, 140, 90, 40);
		this.add(nameTf);
		this.add(psdPf);
		this.add(loginBtn);
		this.add(cancelBtn);
	}
	private void addEvent(){
		loginBtn.addActionListener(this);
		cancelBtn.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
				
			}
		});
	}
	
	public static void main(String[] args) {
		new MyFrame();
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		System.out.println("login......");
		
	}
}





